<!DOCTYPE html>
<html>

	<head>
		<meta charset="UTF-8">

	</head>

	<body>
		<div class="col-lg-12" id="Matchinfo">
			<ol class="breadcrumb">
				<li><i class="fa fa-home"></i>
					<a href="index.html">Home</a>
				</li>
				<li><i class=""></i>发布比赛信息</li>
			</ol>

			<div class="mcomment">
				<h3 class="page-header"><i class=""></i>发布比赛信息</h3>

				<table class=" ">

					<tr>

						<td><label for="matchInfoTitle">标题：</label></td>
						<td><input v-model="title" type="text" class="form-control" id="matchInfoTitle" placeholder="请输入比赛信息标题" /></td>

					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td><label for="matchInfoPerson">主办单位：</label></td>
						<td>
							<select v-model="coId" class="form-control">
								<option v-for="college in collegelist" v-bind:value="college.coId">
									{{college.coName}}
								</option>
							</select>
						</td>
					</tr>

					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>

						<td><label for="inType">参与方式：</label></td>

						<td>
							<select v-model="mode"  class="form-control" id="inType">
								<option>个人</option>
								<option>团队</option>
							</select>
						</td>

					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>

						<td><label for="matchType">比赛类型：</label></td>
						<td>
							<select v-model="comId" class="form-control">
								<option v-for="type in types" v-bind:value="type.comId">
									{{type.laName}}
								</option>
							</select>
						</td>

					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td><label for="matchInfoPerson">联系人：</label></td>
						<td><input v-model="contacts" type="text" class="form-control" id="matchInfoPerson" placeholder="请输入比赛联系人" /></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td><label for="matchInfoPersonTel">联系电话：</label></td>
						<td><input v-model="phone" type="tel" class="form-control" id="matchInfoPersonTel" placeholder="请输入比赛联系人电话" /></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td><label for="matchEnrollTimes">报名时间段：</label></td>
						<td><input v-model="beginenrollTime" type="date" class="form-control" id="matchEnrollStartTimes" /></td>
						<td><span>-</span></td>
						<td><input v-model="endenrollTime" type="date" class="form-control" id="matchEnrollStopTimes" /></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>

					<tr>
						<td><label for="matchTimes">比赛时间段：</label></td>
						<td><input v-model="beginstartTime" type="date" class="form-control" id="matchStartTimes" /></td>
						<td><span>-</span></td>
						<td><input v-model="endstartTime" type="date" class="form-control" id="matchStopTimes" /></td>
					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td colspan="16">

							<label for="noticeContent">比赛内容：</label>
							<!--<script v-model="content1" id="Matchcontent" name="content" type="text/plain">
							</script>-->
							<!--<textarea v-model="content1"   class="form-control" id="Matchnote" cols="100%" rows="10">-->

							<!--</textarea>-->
							<textarea id="text1"    class="form-control" style="display: none" >
								</textarea>
							<div id="meuen" class="toolbar">
							</div>
							<div style="padding: 5px 0; color: #ccc"></div>
							<div id="editor" class="text"> <!--可使用 min-height 实现编辑区域自动增加高度-->
								<p>请输入内容</p>
							</div>
						</td>

					</tr>
					<tr>
						<td>&nbsp;</td>
					</tr>
					<tr>
						<td colspan="16">

							<label for="noticeContent">备注：</label>
							<!--<script v-model="note" id="Matchnote" name="content" type="text/plain">
							</script>-->
							<textarea v-model="note"   class="form-control" id="Matchnote" cols="100%" rows="10">
																															
							</textarea>

						</td>

					</tr>

				</table>

				<center>
					<div style="width: 50%;">
						<button @click="addMatchinfo" class="btn btn-default">发布</button>
						<button class="btn btn-default">取消</button>
					</div>
				</center>

			</div>
		</div>

		<!--<script type="text/javascript">
			//			var ue = UE.getEditor('Matchnote');
						var ue2 = UE.getEditor('Matchcontent');
		</script>-->


		<script type="text/javascript">
			var url1 = 'http://donting.free.idcfengye.com';
//			
			var pmi = new Vue({
				el:'#Matchinfo',
				data:{
					coId: '', //'关联学院'
					collegelist: [], //学院列表
					title: '', //标题
					mode: '个人', //参赛方式'
					beginenrollTime: '', // '报名开始时间',
					endenrollTime: '', // '报名结束时间',
					beginstartTime: '', //'比赛开始时间',
					endstartTime: '', //'比赛结束时间',
					contacts: '', //'联系人',
					phone: '', // '联系电话',
					content1: '', //'比赛内容',
					note: '', //'备注',
					
					
					comId: '', //类型id		
					types: [], //类型列表
				},
				methods: {

					addMatchinfo: function() {
						var x=document.getElementById("text1");

						// alert(x.value);
						pmi.content1=x.value;

						axios.defaults.withCredentials = true;
								console.log(pmi.comId);
						axios.post(url1 + '/details/add', {　
								'coId': pmi.coId, //'关联学院'
								'title': pmi.title, //标题
								'mode': pmi.mode, //参赛方式'
								'enrollTime': pmi.beginenrollTime+'/'+pmi.endenrollTime,  //报名时间
								'startTime': pmi.beginstartTime+'/'+pmi.endstartTime, 	//'比赛时间',
								'contacts': pmi.contacts, //'联系人',
								'phone': pmi.phone, // '联系电话',
								'content': pmi.content1, //'比赛内容',
								'note': pmi.note, //'备注',
								'comId' : pmi.comId,

						}).then(function(response) {
							var rs = response.data;
							console.log(rs.code);　　
							if(rs.code == 200) {

								alert("添加成功!");
							} else {
								alert("添加失败!");
							}

						}).catch(function(error) {　　
							console.log("添加连接超时！");
						});

					},
					
					getcollege:function(){
						axios.defaults.withCredentials = true;
								
						axios.get(url1 + '/college/all', {　
							
						}).then(function(response) {
							var rs = response.data;
							pmi.collegelist = rs.data;
							pmi.coId = rs.data[0].coId;
							
							if(rs.code == 200) {
								
							} else {
								console.log("查看失败!");
							}

						}).catch(function(error) {　　
							console.log("学院连接超时！"+error);
						});
					},

				},
				mounted() {
					
						this.getcollege();
						
						GetType(this);

					var E = window.wangEditor

					var editor =new E('#meuen', '#editor');
					var $text1 = $('#text1')
					editor.customConfig.withCredentials = true
					editor.customConfig.uploadFileName = 'file';
					editor.customConfig.uploadImgServer = url1+'/addEdImgUp'
					editor.customConfig.onchange = function (html) {
						// 监控变化，同步更新到 textarea
						$text1.val(html)
						console.log("更新...")
					}

					editor.create()



				}



			});
		</script>

	</body>

</html>